<?php
	if(!isset($_REQUEST['ajax'])){ $_REQUEST['ajax'] = "";}
	if($_REQUEST['ajax']!=true) include 'header.tpl.php';
?>
	<div class="row">
		<div class="col-lg-12">
			<ul class="shortcut-buttons-set">
				<li>
					<a class="shortcut-button" href='#request_list'><span>
					<i class="aicon-task_list"></i>
					<?php echo $this->language['list'];?></span></a>
				</li>
				<li>
					<a class="shortcut-button" href='#request_list/status=0'><span>
					<i class="aicon-clock"></i>
					<?php echo $this->language['waiting'];?></span></a>
				</li>
				<li>
					<a class="shortcut-button" href='#request_create' ><span>
					<i class="aicon-plus"></i>
					<?php echo $this->language['request_create'];?></span></a>
				</li>
				<?php if(check_permission('request_view')): ?>
				<li>
					<a class="shortcut-button" href='#request_report'><span>
					<i class="aicon-chart"></i>
					Xem báo cáo</span></a>
				</li>
				<?php endif;?>
			</ul>
		</div>
	</div>
	<div class="row">
		<div class="col-lg-12">
			<div class="panel">
				<div class="panel-heading">
					<div class="panel-title"><i class="aicon-task_list"></i> <?php echo $this->language['list'];?></div>
				</div>
				<div class="panel-body">
					<form action="javascript:doSearchReq();" class="form-inline">
						<input type="hidden" id="search_type" value="<?php echo (isset($_REQUEST['type']) && $_REQUEST['type'] == 'CKLED') ? 'CKLED': '';?>" />
						<label><?php echo $this->language['search'];?> :</label>
						<input type="text" class="form-control" placeholder="<?php echo $this->language['code'];?> / <?php echo $this->language['reason'];?>" id="search_tieuchi">
						<select id="search_user" class="form-control">
	                        <option value="0">--- <?php echo $this->language['all'];?> ---</option>
	                    	<?php foreach($_SESSION['room_data'] as $room):?>
							<optgroup label="<?php echo $room['room_name'];?>">
								<?php foreach($room['users'] as $user):?>
								<option value="<?php echo $user['user_id'];?>"><?php echo $user['user_fullname'];?></option>
								<?php endforeach;?>
							</optgroup>
							<?php endforeach;?>
	                    </select>
	                    <select id="search_line" class="form-control">
	                    	<option value="0">--- <?php echo $this->language['all'];?> ---</option>
	                    	<?php foreach($this->lines as $row): ?>
	                    	<option value="<?php echo $row['line_id'];?>"><?php echo $row['line_name'];?></option>
	                    	<?php endforeach;?>
	                    </select>
						<input type="submit" value="<?php echo $this->language['search'];?>" class="btn btn-danger" >
					</form>
					<div class="clear"></div>
		            <table class="table table-fixed table-hover table-condensed">
						<thead>
							<tr>
								<th width='20px'>&nbsp;</th>
								<th width='20px'>&nbsp;</th>
								<th width='70px'>Mã số</th>
								<th width='130px'>Họ và tên</th>
								<th>Lý do</th>
								<th width='85px'>Số tiền</th>
								<th width='80px'>Ngày tạo</th>
								<th width='110px'>Tình trạng</th>
								<th width='50px'>&nbsp;</th>
							</tr>
						</thead>
						<tbody>
							<?php if(isset($this->requests)){
								foreach($this->requests as $row){ ?>
							<tr>
								<td><?php echo $row['attach'];?></td>
								<td><?php echo ($row['return_status']) ? '<font color="green"><i class="icon-checkmark"></i></font>' :'&nbsp;';?></td>
								<td><a href='#request_view/id=<?php echo $row['req_id'];?>'><?php echo ($row['return_id']) ? '<font color="green">' : '<font color="red">';?><?php echo $row['req_code'];?></font></a></td>
								<td><?php echo $_SESSION['user_data'][$row['user_id']]['fullname'];?></td>
								<td><a href='#request_view/id=<?php echo $row['req_id'];?>'><?php echo $row['req_reason'];?></a></td>
								<td><font color=red><?php echo number_format($row['amount'],0,'',',');?></font></td>
								<td><?php echo date("d/m/Y",$row['req_date']);?></td>
								<td class="text-center">
								<?php
									if($row['req_signature1']=='0') echo "<span class='label label-waiting'>Chờ Duyệt</span>";
									elseif($row['req_status']=='0') echo "<span class='label label-process'>Đã Duyệt - Chưa Chi</span>";
									elseif($row['req_status']=='1') echo "<span class='label label-preview'>Đã Duyệt - Đã Chi</span>";
									elseif($row['req_status']=='2') echo "<span class='label label-complete'>Đã Hoàn Thành</span>";
									else echo "<span class='label label-deny'>Không biết</span>";
								?>
								</td>
								<td>
									<a href='#request_view/id=<?php echo $row['req_id'];?>'><img src="resources/images/icons/view.png" /></a>
									<a href='javascript:;' onClick="deletePTU('<?php echo $row['req_code'];?>');"><img src="resources/images/icons/cross.png" /></a>
								</td>
							</tr>
							<?php }} ?>
						</tbody>
						<?php if(isset($this->tfoot)) echo $this->tfoot;?>
					</table>
				</div>
			</div>
		</div>
	</div>
<?php if(isset($this->breadcrumb) && isset($this->title_header)):?>
	<script type="text/javascript">
		$(function() {
			$("#title-header").text('<?php echo $this->title_header;?>');
			$("#breadcrumb").html('<?php echo build_breadcrumb($this->breadcrumb);?>');
		});
	</script>
<?php endif;?>
<?php
	if($_REQUEST['ajax']!=true) include 'footer.tpl.php';
?>